/**
 * 
 */
package com.rc.object;

import java.io.File;

import com.rc.util.Util;

import android.content.ContentValues;
import android.content.Context;
import android.graphics.Bitmap;

/**
 * @author NTH
 * 
 */
public class BaseObject {
	/**
	 * 
	 */
	public static String[] no_key = {};
	public static String[] other_keys = { "packed_url", "join_status",
			"currentCheckPointIndex" };

	public static String PACKED_URL = other_keys[0];
	public static String JOIN_STATUS = other_keys[1];
	public static String CURRENT_CHECKPOINT_INDEX = other_keys[2];
	public static String DATA = "data";
	public static String SUCCESS = "success";
	public static String FAIL = "fails";
	/**
	 * params for this item
	 */
	protected ContentValues params = null;
	private boolean isChecked;

	public boolean isChecked() {
		return isChecked;
	}

	public void setChecked(boolean isChecked) {
		this.isChecked = isChecked;
	}

	/**
	 * Set the params for this item
	 * 
	 * @param params
	 */
	public void setParams(ContentValues params) {
		this.params = params;
	}

	/**
	 * Get the params for this item
	 * 
	 * @param params
	 */
	public ContentValues getParams() {
		return params;
	}

	/**
	 * 
	 * @param key
	 * @return
	 */
	public String getParam(String key) {
		if (params != null)
			return Util.formatString(params.getAsString(key));
		else
			return null;
	}

	public boolean getParamBoolean(String key) {
		if (params != null)
			return params.getAsBoolean(key);
		else
			return false;
	}

	/**
	 * 
	 * @param key
	 * @param value
	 */
	public void setParam(String key, String value) {
		if (params == null)
			params = new ContentValues();
		params.put(key, value);

	}

	public void setParamBoolean(String key, boolean value) {
		if (params == null)
			params = new ContentValues();
		params.put(key, value);

	}

	public void setParamInt(String key, int value) {
		if (params == null)
			params = new ContentValues();
		params.put(key, value);
	}

	public void setParamLong(String key, long value) {
		if (params == null)
			params = new ContentValues();
		params.put(key, value);
	}

	public int getParamInt(String key) {
		// nth
		if (key.equals("null")) {
			return 0;
		}
		if (params != null)
			if (params.containsKey(key) && params.getAsInteger(key) != null)
				return params.getAsInteger(key);
		return 0;
	}

	public long getParamLong(String key) {
		// nth
		if (key.equals("null")) {
			return 0;
		}
		if (params != null)
			if (params.containsKey(key) && params.getAsLong(key) != null)
				return params.getAsLong(key);
		return 0;
	}

	public File GetItemBitmapFile(Context context) {
		return null;
	}

	/**
	 * 
	 * @param context
	 * @return
	 */
	public Bitmap GetItemThumbnailBitmapSync(Context context) {

		return null;
	}

	/**
	 * 
	 * @param context
	 * @return
	 */
	public Bitmap GetItemBitmapSync(Context context) {
		return null;
	}

	/**
	 * Check if bitmap file for this item is exist or not
	 * 
	 * @param context
	 * @return
	 */
	public boolean isItemBitmapAvailable(Context context) {
		return false;
	}

	// public int SaveBitmap(Context context, Bitmap bitmap) {
	// return Definications.RESULT_FAILED;
	// }

}
